package org.rebluh.hulunbuirtravelnetworkbackendframework.controller;

import org.rebluh.hulunbuirtravelnetworkbackendframework.domain.Hulber;
import org.rebluh.hulunbuirtravelnetworkbackendframework.domain.Image;
import org.rebluh.hulunbuirtravelnetworkbackendframework.dto.HulberImagesDTO;
import org.rebluh.hulunbuirtravelnetworkbackendframework.service.HulberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Optional;

@RestController
@RequestMapping("/hulber")
public class HulberController {
    @Autowired
    private HulberService hulberService;

    //添加景点
    @PostMapping
    public Hulber createHulber(@RequestBody Hulber hulber) {
        return hulberService.createHulber(hulber);
    }

    //根据id获取景点
    @GetMapping("/{id}")
    public Optional<Hulber> getAllHulberById(@PathVariable("id") String id) {
        return hulberService.getHulberById(id);
    }

    //获取全部景点
    @GetMapping
    public List<Hulber> getAllHulbers() {
        return hulberService.getAllHulber();
    }

    //根据给出的类型查询景区带图片
    @GetMapping("/get")
    public List<HulberImagesDTO> getHulberImagesByKey(@RequestParam String key) {
        return hulberService.getHulberImagesByKey(key);
    }


}
